import url from '@/tool/index.js'

//我的钱包
export const myWallet = () => { //
	return new Promise(resolve => {
		uni.request({
			url: url+'/api/user.user/mywallet',
			data: {
				token:uni.getStorageSync('userToken')
			},
			method: 'get',
			success: (res) => resolve(res.data),
		});
	})
}
//我的优惠券
export const myCoupon = (ctype=1,page=1) => { //
	return new Promise(resolve => {
		uni.request({
			url: url+'/api/user.user/mycoupon',
			data: {
				token:uni.getStorageSync('userToken'),
				ctype:ctype,
				page:page
			},
			method: 'get',
			success: (res) => resolve(res.data),
		});
	})
}
//余额充值
export const addOrder = (balanceid,realname,mobile) => { //
	return new Promise(resolve => {
		uni.request({
			url: url+'/api/user.balance/addOrder',
			data: {
				token:uni.getStorageSync('userToken'),
				balanceid:balanceid,
				realname:realname,
				mobile:mobile
			},
			method: 'POST',
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			success: (res) => resolve(res.data),
		});
	})
}
//充值金额列表
export const lists = () => { //
	return new Promise(resolve => {
		uni.request({
			url: url+'/api/user.balance/lists',
			data: {
				token:uni.getStorageSync('userToken')
			},
			method: 'get',
			success: (res) => resolve(res.data),
		});
	})
}
//充值明细
export const buybalanceorder = (page=1) => { //
	return new Promise(resolve => {
		uni.request({
			url: url+'/api/user.balance/buybalanceorder',
			data: {
				page:page,
				token:uni.getStorageSync('userToken')
			},
			method: 'get',
			success: (res) => resolve(res.data),
		});
	})
}
//使用明细
export const usebalancelog = () => { //
	return new Promise(resolve => {
		uni.request({
			url: url+'/api/user.balance/usebalancelog',
			data: {
				token:uni.getStorageSync('userToken')
			},
			method: 'get',
			success: (res) => resolve(res.data),
		});
	})
}